home *** CD-ROM | disk | FTP | other *** search
/ Enter 2003 April / EnterCD 4_2003.iso / Multimedia / AlbumCreator 2.5 / AC2.exe / resizewin.js < prev    next >
Encoding:
JavaScript  |  2002-07-24  |  2.6 KB  |  100 lines

  1. /*****
  2. * [resizewin.js] v2.1
  3. * 2001-08-05
  4. * Author: Anarchos
  5. * E-mail: anarchos3@hotmail.com
  6. * URL: http://anarchos.xs.mw/
  7. ***/
  8.  
  9. function resizeWin(maxX,maxY,speed,delay,win){
  10.     this.obj = "resizeWin" + (resizeWin.count++);
  11.     eval(this.obj + "=this");
  12.     if (!win)     this.win = self;    else this.win = eval(win);
  13.     if (!maxX)    this.maxX = 400;    else this.maxX = maxX;
  14.     if (!maxY)    this.maxY = 300;    else this.maxY = maxY;
  15.     if (!speed)   this.speed = 1/5;   else this.speed = 1/speed;
  16.     if (!delay)   this.delay = 0;    else this.delay = delay;
  17.     this.doResize = (document.all || document.getElementById);
  18.     this.stayCentered = false;
  19.     
  20.     this.initWin =     function(){
  21.         if (this.doResize){
  22.             this.resizeMe();
  23.             }
  24.         else {
  25.             this.win.resizeTo(this.maxX + 10, this.maxY - 20);
  26.             }
  27.         }
  28.  
  29.     this.resizeMe = function(){
  30.         this.win.focus();
  31.         this.updateMe();
  32.         }
  33.     
  34.     this.resizeTo = function(x,y){
  35.         this.maxX = x;
  36.         this.maxY = y;
  37.         this.resizeMe();
  38.         }
  39.         
  40.     this.stayCentered = function(){
  41.         this.stayCentered = true;
  42.         }
  43.  
  44.     this.updateMe = function(){
  45.         this.resizing = true;
  46.         var x = Math.ceil((this.maxX - this.getX()) * this.speed);
  47.         var y = Math.ceil((this.maxY - this.getY()) * this.speed);
  48.         if (x == 0 && this.getX() != this.maxX) {
  49.             if (this.getX() > this.maxX) x = -1;
  50.             else  x = 1;
  51.             }
  52.         if (y == 0 && this.getY() != this.maxY){
  53.             if (this.getY() > this.maxY) y = -1;
  54.             else y = 1;
  55.             }
  56.         if (x == 0 && y == 0) {
  57.             this.resizing = false;
  58.             }
  59.         else {
  60.             this.win.top.resizeBy(parseInt(x),parseInt(y));
  61.             if (this.stayCentered == true) this.win.moveTo((screen.width - this.getX()) / 2,(screen.height - this.getY()) / 2);
  62.             setTimeout(this.obj + '.updateMe()',this.delay)
  63.             }
  64.         }
  65.         
  66.     this.write =  function(text){
  67.         if (document.all && this.win.document.all["coords"]) this.win.document.all["coords"].innerHTML = text;
  68.         else if (document.getElementById && this.win.document.getElementById("coords")) this.win.document.getElementById("coords").innerHTML = text;
  69.         }
  70.         
  71.     this.getX =  function(){
  72.         if (document.all) return (this.win.top.document.body.clientWidth + 10)
  73.         else if (document.getElementById)
  74.             return this.win.top.outerWidth;
  75.         else return this.win.top.outerWidth - 12;
  76.     }
  77.     
  78.     this.getY = function(){
  79.         if (document.all) return (this.win.top.document.body.clientHeight + 29)
  80.         else if (document.getElementById)
  81.             return this.win.top.outerHeight;
  82.         else return this.win.top.outerHeight - 31; 
  83.     }
  84.     
  85.     this.onResize =  function(){
  86.         if (this.doResize){
  87.             if (!this.resizing) this.resizeMe();
  88.             }
  89.         }
  90.  
  91.     return this;
  92. }
  93. resizeWin.count = 0;
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.